<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta charset="utf-8">
    <title>会员约课</title>
    <link rel="shortcut icon" href="${pageContext.request.contextPath}/favicon.ico"/>
    <link rel="bookmark" href="${pageContext.request.contextPath}/favicon.ico"/>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/webjars/layui/css/layui.css" media="all">
    <script type="application/javascript" src="${pageContext.request.contextPath}/webjars/layui/layui.js"
            charset="utf-8"></script>
    <script type="application/javascript" src="${pageContext.request.contextPath}/webjars/jquery/jquery.js"></script>
    <script type="application/javascript"
            src="${pageContext.request.contextPath}/private/js/loading/ajaxloading.js"></script>
</head>
<body>
<fieldset class="layui-elem-field">
    <legend>会员约课编辑</legend>
    <form id="form1" class="layui-form" action="">
        <table width="96%" align="center">
            <tr height="23">
                <td align="center">消耗课时数:</td>
                <td align="left">
                    <input type="hidden" id="appointmentid" name="appointmentid" value="${appointmentid}"/>
                    <input id="consumes" name="consumes" class="layui-input" type="text" placeholder="请输入消耗的课时数"
                           autocomplete="off" lay-verify="number">
                </td>
            </tr>
            <tr height="23">
                <td align="center">约课状态:</td>
                <td align="left">
                    <select id="status" name="status" lay-verify="status">
                        <option value="">请选择课程完成情况</option>
                        <option value="2">已签到</option>
                        <option value="3">取消预约</option>
                    </select>
            </tr>

            <tr height="50">
                <td align="center">
                    <button id="formsubmit" class="layui-btn" lay-submit lay-filter="updateappointmentinfo">保存</button>
                </td>
            </tr>
        </table>
    </form>
</fieldset>

</body>
<script type="application/javascript">
    layui.use('form', function () {
        var form = layui.form;
        form.verify({
            status: function(value){
                if(!value) {
                    return '约课状态不能为空';
                }
            }
        });
        //监听提交
        form.on('submit(updateappointmentinfo)', function (data) {
            $.ajax({
                url:"${pageContext.request.contextPath}/eyas/appointmentinfo/updateAppointmentInfo",
                type:"POST",
                data:data.field,
                dataType:"json",
                success:function(result){
                    layer.msg("保存成功,页面将在1秒后关闭");
                    setTimeout(function () {
                        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                        parent.layer.close(index); //再执行关闭
                    },1000);
                },
                error:function(xdata){
                    layer.msg(xdata.responseJSON.errormsg);
                }
            });
            return false;
        });
    });

</script>
</html>
